package com.cherrypt.api.core.service;

import com.baomidou.mybatisplus.extension.service.IService;
import com.cherrypt.api.common.enums.UserInfoEnum;
import com.cherrypt.api.common.exception.TipException;
import com.cherrypt.api.model.dataobject.UserInfo;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author intent
 * @date 2019/7/14 16:39
 * @about <link href='http://zzyitj.xyz/'/>
 */
public interface UserInfoService extends IService<UserInfo> {
    /**
     * 注册用户
     *
     * @param userInfo
     * @return
     */
    @Transactional
    boolean saveUserInfo(UserInfo userInfo);

    /**
     * 根据id获取Redis中的UserInfo
     *
     * @param uid uid
     * @return
     */
    UserInfo getRedisUserInfoByUid(int uid);

    /**
     * 存储UserInfo
     *
     * @param userInfo
     */
    void saveRedisUserInfo(UserInfo userInfo);

    /**
     * 移除
     *
     * @param uid
     */
    boolean removeRedisUserInfo(int uid);

    UserInfo getUserInfoByUid(int uid) throws TipException;

    UserInfo getFriendByUid(int uid);

    UserInfo getUserByUsername(String username) throws TipException;

    UserInfo getUserInfoByPasskey(String passkey) throws TipException;

    /**
     * 更新UserInfo
     *
     * @param userInfo
     * @return
     */
    @Transactional
    boolean updateUserInfoByUid(UserInfo userInfo);

    @Transactional
    boolean updateUDByUid(int uid, long upload, long download);

    /**
     * 更新exp
     *
     * @param uid
     * @param exp
     * @return
     */
    @Transactional
    boolean updateExpByUid(int uid, long exp);

    @Transactional
    boolean updateStatusByUid(int uid, UserInfoEnum userInfoEnum);
}
